android studio 自定义edittext光标下划线颜色 | 您所在的位置:网站首页 › android studio文本框背景颜色 › android studio 自定义edittext光标下划线颜色 |
原本效果: 更改后: 光标为f00红色,edittext选中时下划线为999灰色,未被选中时为f40淘宝红,且添加了左内边框。 修改流程如下: 首先在res>drawable下创建光标的样式文件。 代码如下: 然后是下划线的颜色样式,在res>values>styles.xml添加自己样式块“MyEditText”; 代码如下: -- Base application theme. --> -- Customize your theme here. --> @color/colorPrimary @color/colorPrimaryDark @color/colorAccent --未被选中时下划线的颜色--> #f40 --输入框的左内边框--> 90px --文本的颜色--> #000 --被选中时下划线的颜色--> #999最后在activity中添加edittext,并在对应的layout xml文件添加样式: 代码如下: android:textCursorDrawable=”@drawable/textcursorcolor” android:theme=”@style/MyEditText” 至此已完成对edittext光标和下划线颜色的改变,另外如果想单纯的去除下滑线的话只需将背景设置为空即可: android:background=”@null” 源码地址:https://download.csdn.net/download/qq_39143010/10671971 |
CopyRight 2018-2019 实验室设备网 版权所有 |